import api from './index'
// axios
import request from '@/utils/request'
import md5 from 'js-md5'
import { sha256 } from 'js-sha256'

/* 登录 */
export function login(info) {
  const { type, account, smscode, password } = info
  const ts = Date.parse(new Date()) / 1000 + ''
  const passwd = sha256.hmac('wpyx.A1101', md5(password) + ts)
  const data = {
    type,
    ts,
    smscode,
    account,
    passwd
  }
  return request({
    url: '/portal/login',
    method: 'post',
    data
  })
}

/* 短信发送 */
export function getSms(data) {
  return request({
    url: '/sms',
    method: 'post',
    data
  })
}

// 获取地理
export function geosList() {
  return request({
    url: '/geos',
    method: 'get'
  })
}

// 获取科目
export function getSubjectList() {
  return request({
    url: '/common/cates',
    method: 'get'
  })
}

// 用户信息 post 方法
export function getUserInfo(data) {
  return request({
    url: api.UserInfo,
    method: 'post',
    data,
    hideloading: true
  })
}

// 用户名称 get 方法
export function getUserName(params) {
  return request({
    url: api.UserName,
    method: 'get',
    params,
    hideloading: true
  })
}
